/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sky
 */
@Entity
@Table(name = "ARTIST")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Artist.findAll", query = "SELECT a FROM Artist a"),
    @NamedQuery(name = "Artist.findByArtistId", query = "SELECT a FROM Artist a WHERE a.artistId = :artistId"),
    @NamedQuery(name = "Artist.findByArtistFname", query = "SELECT a FROM Artist a WHERE a.artistFname = :artistFname"),
    @NamedQuery(name = "Artist.findByArtistLname", query = "SELECT a FROM Artist a WHERE a.artistLname = :artistLname"),
    @NamedQuery(name = "Artist.findByArtistArtname", query = "SELECT a FROM Artist a WHERE a.artistArtname = :artistArtname"),
    @NamedQuery(name = "Artist.findByArtistSex", query = "SELECT a FROM Artist a WHERE a.artistSex = :artistSex"),
    @NamedQuery(name = "Artist.findByArtistBirthDay", query = "SELECT a FROM Artist a WHERE a.artistBirthDay = :artistBirthDay"),
    @NamedQuery(name = "Artist.findByArtistBirthPlace", query = "SELECT a FROM Artist a WHERE a.artistBirthPlace = :artistBirthPlace")})
public class Artist implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    @Column(name = "ARTIST_BIRTH_DAY")
    private Integer artistBirthDay;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ARTIST_ID")
    private Long artistId;
    @Basic(optional = false)
    @Column(name = "ARTIST_FNAME")
    private String artistFname;
    @Basic(optional = false)
    @Column(name = "ARTIST_LNAME")
    private String artistLname;
    @Column(name = "ARTIST_ARTNAME")
    private String artistArtname;
    @Basic(optional = false)
    @Column(name = "ARTIST_SEX")
    private String artistSex;
    @Column(name = "ARTIST_BIRTH_PLACE")
    private String artistBirthPlace;
    @JoinColumn(name = "MUSIC_GENRE_ID", referencedColumnName = "MUSIC_GENRE_ID")
    @ManyToOne(optional = false)
    private MusicGenre musicGenreId;
    @JoinColumn(name = "ARTIST_MUSIC_GROUP_ID", referencedColumnName = "MUSIC_GROUP_ID")
    @ManyToOne
    private MusicGroup artistMusicGroupId;
    @OneToMany(mappedBy = "artistId")
    private List<Album> albumList;

    public Artist() {
    }

    public Artist(Long artistId) {
        this.artistId = artistId;
    }

    public Artist(Long artistId, String artistFname, String artistLname, String artistSex) {
        this.artistId = artistId;
        this.artistFname = artistFname;
        this.artistLname = artistLname;
        this.artistSex = artistSex;
    }

    public Long getArtistId() {
        return artistId;
    }

    public void setArtistId(Long artistId) {
        Long oldArtistId = this.artistId;
        this.artistId = artistId;
        changeSupport.firePropertyChange("artistId", oldArtistId, artistId);
    }

    public String getArtistFname() {
        return artistFname;
    }

    public void setArtistFname(String artistFname) {
        String oldArtistFname = this.artistFname;
        this.artistFname = artistFname;
        changeSupport.firePropertyChange("artistFname", oldArtistFname, artistFname);
    }

    public String getArtistLname() {
        return artistLname;
    }

    public void setArtistLname(String artistLname) {
        String oldArtistLname = this.artistLname;
        this.artistLname = artistLname;
        changeSupport.firePropertyChange("artistLname", oldArtistLname, artistLname);
    }

    public String getArtistArtname() {
        return artistArtname;
    }

    public void setArtistArtname(String artistArtname) {
        String oldArtistArtname = this.artistArtname;
        this.artistArtname = artistArtname;
        changeSupport.firePropertyChange("artistArtname", oldArtistArtname, artistArtname);
    }

    public String getArtistSex() {
        return artistSex;
    }

    public void setArtistSex(String artistSex) {
        String oldArtistSex = this.artistSex;
        this.artistSex = artistSex;
        changeSupport.firePropertyChange("artistSex", oldArtistSex, artistSex);
    }

    public String getArtistBirthPlace() {
        return artistBirthPlace;
    }

    public void setArtistBirthPlace(String artistBirthPlace) {
        String oldArtistBirthPlace = this.artistBirthPlace;
        this.artistBirthPlace = artistBirthPlace;
        changeSupport.firePropertyChange("artistBirthPlace", oldArtistBirthPlace, artistBirthPlace);
    }

    public MusicGenre getMusicGenreId() {
        return musicGenreId;
    }

    public void setMusicGenreId(MusicGenre musicGenreId) {
        MusicGenre oldMusicGenreId = this.musicGenreId;
        this.musicGenreId = musicGenreId;
        changeSupport.firePropertyChange("musicGenreId", oldMusicGenreId, musicGenreId);
    }

    public MusicGroup getArtistMusicGroupId() {
        return artistMusicGroupId;
    }

    public void setArtistMusicGroupId(MusicGroup artistMusicGroupId) {
        MusicGroup oldArtistMusicGroupId = this.artistMusicGroupId;
        this.artistMusicGroupId = artistMusicGroupId;
        changeSupport.firePropertyChange("artistMusicGroupId", oldArtistMusicGroupId, artistMusicGroupId);
    }

    @XmlTransient
    public List<Album> getAlbumList() {
        return albumList;
    }

    public void setAlbumList(List<Album> albumList) {
        this.albumList = albumList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (artistId != null ? artistId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Artist)) {
            return false;
        }
        Artist other = (Artist) object;
        if ((this.artistId == null && other.artistId != null) || (this.artistId != null && !this.artistId.equals(other.artistId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Artist[ artistId=" + artistId + " ]";
    }

    public Integer getArtistBirthDay() {
        return artistBirthDay;
    }

    public void setArtistBirthDay(Integer artistBirthDay) {
        Integer oldArtistBirthDay = this.artistBirthDay;
        this.artistBirthDay = artistBirthDay;
        changeSupport.firePropertyChange("artistBirthDay", oldArtistBirthDay, artistBirthDay);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
